FROM node:lts-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm config set registry https://registry.npm.taobao.org \
    && npm install
COPY . .
RUN npm run build

FROM nginx:alpine as final
COPY --from=build /app/dist /usr/share/nginx/html
RUN sed -i 'N;10 a try_files $uri $uri/ /index.html;' /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]